package priv.bestbeat.cloud.api.gateway.session;

import priv.bestbeat.cloud.api.gateway.exceptions.SessionOperationException;

/**
 * session 存储库
 * @author 张渠钦
 * @date 2021/12/7 17:52
 */
public interface SessionRepository<P,T> {

    /**
     * 存储session
     * @param principal session主体唯一标识
     * @param session
     */
    void saveSession(P principal,T session) throws SessionOperationException;

    /**
     * 根据 principal 获取 session
     * @param principal session主体唯一标识
     * @return session
     */
    T getSession(P principal) throws SessionOperationException;

    /**
     * 根据 principal 清除 session
     * @param principal session主体唯一标识
     */
    void clearSession(P principal) throws SessionOperationException;

    /**
     * 清除所有session
     */
    void clearAll() throws SessionOperationException;

}
